Skip to content

[Performance] Move Search and submit-expense onto write-readiness barriers and delete deferredLayoutWrite - #100169

Merged
roryabraham merged 23 commits into
Expensify:mainfrom
software-mansion-labs:korytko/writewhenready-cutover
Sep 24, 2026
Merged

roryabraham merged 23 commits into
Expensify:mainfrom
software-mansion-labs:korytko/writewhenready-cutover

Conversation

@JakubKorytko

@JakubKorytko JakubKorytko commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

Submitting an expense from a report, Search or global create used to defer its API write through the deferredLayoutWrite "channel" system, so the optimistic data would land only after the screen transition finished. That system was implicit: the write had to guess which channel would be flushed, and any screen that forgot to flush left writes stuck.

This PR switches every submit path (request money, track expense, split, send money, invoice, per diem) and Search over to the explicit write-readiness barriers that already landed on main. The submit orchestrator arms one barrier for the transition and hands it to the action it calls, so each write knows exactly what it waits for. Search owns its own barrier and releases it once its layout is ready, on focus, on a timeout fallback, or when the app goes to background. A small pending-write signal replaces the old report-side flag that drove the loading skeleton and empty-state animation.

With all callers moved, the old channel system (deferredLayoutWrite, the global-create Search reservation helper, the flush-on-focus hook, and the related CONST keys) is unreferenced, so it is deleted in the same PR. Keeping replacement and removal together avoids leaving ~700 lines of dead code on main between two PRs. No new modules are added here: the change is rewiring plus deletion.

Fixed Issues

$ #96010
PROPOSAL: N/A

Tests

T1. Inbox dismiss-only

  1. Open Inbox -> Workspace A your expenses chat
  2. "+" in the composer -> "Create expense" -> "Manual"
  3. Fill the details (Amount, Merchant, Description, Category) and submit (Green "Create expense" button)
  4. Confirm the modal dismisses without visible lag and the expense appears in the chat

T2. Inbox open report

  1. Narrow: Open Inbox chat list / Wide: Open Inbox -> Workspace B your expenses chat
  2. FAB -> "Create expense" -> "Manual" -> Select Workspace A your expenses
  3. Fill the details (Amount, Merchant, Category, Description) and submit (Green "Create expense" button)
  4. Verify the workspace A expenses chat opens without visible lag and the expense appears in the chat
  5. Repeat steps 1-3 with a workspace that has no open report yet, or with "Report" set to "New report" on the form
  6. Verify the new report opens with a loading skeleton at most briefly, then the single expense, no empty state flashes

T3. Search skeleton

  1. Open Spend -> Expenses
  2. FAB -> "Create expense" -> "Manual" -> Select Workspace A your expenses
  3. Fill the details and submit
  4. Verify the new row appears in the table exactly once
  5. Repeat steps 2-4 without leaving the page

T4. Search bulk split

  1. Open Spend -> Expenses
  2. Open filters, select "From" and any user you already have expenses from (yourself is okay as well)
  3. Select one expense -> "1 selected" -> "Split" -> "Save"
  4. Verify two split rows appear and the original does not become "Unreported"

T5. Other expense types (Inbox, Workspace A expenses chat)

  1. Composer "+" -> "Create expense" -> "Scan" -> upload a receipt -> submit
  2. Composer "+" -> "Create expense" -> "Time" -> enter hours -> submit
  3. Composer "+" -> "Track distance" -> "Manual" -> enter distance -> submit
  4. Composer "+" -> "Create expense" -> "Per diem" -> pick destination, dates, subrate -> submit
  5. Verify each expense appears in the chat right after its modal dismisses

T6. Split and pay (DM with another user)

  1. Composer "+" -> "Split expense" -> "Manual" -> fill amount -> "Split expense"
  2. Composer "+" -> "Split expense" -> "Scan" -> Upload receipt -> Create expense
  3. Composer "+" -> "Pay " -> fill amount -> "Pay" -> "Mark as paid"
  4. Verify the split preview, both scanning rows and the paid preview appear in the DM
  5. Open Spend -> Expenses, FAB -> quick action "Pay " -> fill amount -> "Pay" -> "Mark as paid"
  6. Verify the paid row appears in the table exactly once
  7. Back in the DM repeat step 2, then open Spend -> Expenses, FAB -> quick action "Split receipt" -> Upload receipt -> Create expense
  8. Verify both scanning rows appear in the table exactly once

T7. Send invoice

  1. Open Inbox
  2. FAB -> "Send invoice" -> amount -> recipient -> merchant -> company info if asked -> "Send ... invoice"
  3. Verify the invoice chat opens with the invoice preview
  4. Open Spend -> Expenses, repeat step 2
  5. Verify the invoice row appears in the table exactly once

T8. Read during deferral

  1. Repeat T1 steps 1-3
  2. Immediately after submit open a different chat from the Inbox list
  3. Verify it loads normally, not stuck on a loading state

T9. Background (native only)

  1. Repeat T3 steps 1-3, background the app within a second
  2. Reopen after a few seconds
  3. Verify the expense row is present and no skeleton is stuck

T10. Quick action scan (workspace without required categories)

  1. In Workspace A expenses chat run Composer "+" -> "Create expense" -> "Scan" once so the quick action becomes "Scan receipt"
  2. Open Spend -> Expenses, FAB -> quick action "Scan receipt" -> upload a receipt
  3. Verify the scanning row appears in the table exactly once and no skeleton is stuck

Offline tests

  1. Go offline, repeat T1. Verify the expense preview appears greyed out with the pending indicator
  2. Still offline, repeat T3 once. Verify the row appears once, greyed out
  3. Go online. Verify both sync and the pending indicator clears

QA Steps

Same as tests.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS_gh.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
Web.mp4

@Julesssss

Copy link
Copy Markdown
Contributor

@claude review

@JakubKorytko

Copy link
Copy Markdown
Member Author

@codex review

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.06% <ø> (ø)
src/hooks/useSearchOverlay.tsx 57.14% <100.00%> (ø)
src/hooks/useSearchPageSetup.ts 97.14% <100.00%> (ø)
src/libs/API/writeWhenReady.ts 98.66% <100.00%> (ø)
src/libs/IOUAmountSubmission.ts 86.63% <100.00%> (-0.15%) ⬇️
src/libs/MoneyRequestReportUtils.ts 90.54% <100.00%> (ø)
.../libs/Navigation/helpers/submitWithDismissFirst.ts 83.63% <100.00%> (ø)
src/libs/actions/IOU/MoneyRequestBuilder.ts 90.63% <ø> (ø)
src/libs/actions/IOU/SendInvoice.ts 93.79% <100.00%> (+0.61%) ⬆️
src/libs/actions/IOU/Split.ts 77.93% <100.00%> (+0.22%) ⬆️
... and 16 more
... and 7 files with indirect coverage changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 429ce349fd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/actions/IOU/TrackExpense.ts Resolved
@JakubKorytko

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 429ce349fd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@JakubKorytko

Copy link
Copy Markdown
Member Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Code review

The cutover itself looks correct. I traced every path that used to reserve a deferredLayoutWrite channel and each one now raises an equivalent signal, including the non-obvious ones — the old deferOrExecuteWrite SEARCH fallback that caught submitWithDismissFirst's send-money write is preserved by resolveWriteBarrier's automatic hasPendingSearchWrite() check, and no references to the deleted module or CONST.DEFERRED_LAYOUT_WRITE_KEYS are left anywhere in src/ or tests/. Deleting the old system in the same PR is the right call.

Nothing blocking. Two things I'd want answered before merge (2 and 3), plus stale-comment cleanup.

1. Dangling identifier in a comment

src/components/Search/index.tsx:426 says the optimistic data comes from flushWriteSession. No such function exists — it's flushPendingSearchWrite.

Same for "write session", which isn't a concept in the codebase, at SubmitExpenseOrchestrator.tsx:286 ("the same point the write session used to drop this signal") and :426 ("matching where the flushed session used to drop it"). These read like leftovers from an earlier naming pass, and they're the comments a future reader will lean on hardest.

2. notifyNewAction ordering is now inconsistent across submit paths

writeWhenReady always defers by at least a microtask, even with an already-resolved barrier. So anything sitting synchronously after the call now runs before the optimistic data lands — where the immediate deferOrExecuteWrite path used to run after it.

You handled this in SendMoney by moving the notify into onWriteStarted (SendMoney.ts:562), but three siblings still call it inline:

notifyNewAction fires a synchronous subscriber callback into ReportActionsList, so the list gets poked before the new action exists. Deliberate, or should these get onWriteStarted too? The same question applies to startSplitBill's if (shouldHandleNavigation) block, which now navigates before the write.

3. Deferred writes now hold the READ gate

writeWhenReady defaults to shouldClaimReadGate: true. deferredLayoutWrite never touched the sequential queue — the write simply didn't exist until flush, so READs went through. Now every deferred submit write parks READs for as long as its barrier holds, worst case SAFETY_TIMEOUT_MS (5 × MAX_TRANSITION_DURATION_MS = 5s) if nothing releases it.

For the IMMEDIATE and armed-transition barriers that's a microtask and irrelevant. For the Search barrier — released on real-content layout, focus, or timeout — it's a genuinely open window. Worth confirming this is wanted rather than inherited from the default, and whether {shouldClaimReadGate: false} fits the Search paths.

4. Eight test files keep a comment for the mock you deleted

The jest.mock('@libs/deferredLayoutWrite', ...) blocks are gone but the comment above them survived: "In production, requestMoney defers its API.write() call... so we bypass the deferral by executing the callback immediately." Nothing bypasses anything now — writeWhenReady runs for real in these tests. Affected: tests/actions/IOU/{CreateDraftTransactionTest,MoneyRequestBuilderTest,MoneyRequestSettersTest,RequestMoneyTest,SearchUpdateTest,SplitReportTotalsTest}.ts and tests/actions/{TransactionTest,OdometerTransactionUtilsTest}.ts.

5. Minor

  • Armed barrier's cancel is discarded. SubmitExpenseOrchestrator.tsx:249 and :279 both take armTransitionBarrier().barrier and drop cancel, which ArmedTransitionBarrier documents as "drops the registration if the write never happens." createTransaction early-returns in several places (blockDistanceRequestIfNeeded, empty transactions, missing login), so the TransitionTracker registration can outlive the flow. No user-visible effect, just an untidy leak.
  • restartPendingSubmitWriteSafetyTimeout has no production caller. It's exported and unit-tested, and resolveWriteBarrier calls the Search equivalent (restartPendingSearchWriteSafetyTimeoutForGeneration), but the report-scoped one is never invoked. This PR is what makes pendingSubmitWrite live, so either it should be wired up or it's dead weight.
  • MoneyRequestReportUtils.ts:156 still names the local hasPendingDismissWrite — the "dismiss" framing is gone now.
  • IOUAmountSubmission.ts:310: executeSendMoneyWrite no longer takes arguments, so executeWrite: () => executeSendMoneyWrite() can just be executeWrite: executeSendMoneyWrite.
  • The PR is still [WIP] with every author-checklist box ticked but all five Screenshots/Videos sections empty. Given this rewires all six submit paths, the platform videos are the main evidence a reviewer has.

Next Steps: Reply with @MelvinBot <your feedback> to refine this review.

@JakubKorytko

Copy link
Copy Markdown
Member Author

@MelvinBot

  1. Fixed.
  2. Moved notifyNewAction into onWriteStarted for the three Split paths and PerDiem. Note main already notified before the write in the deferred case, only the immediate path changed. startSplitBill navigating first is intentional.
  3. Intentional. Gate was added in [No QA] Claim the sequential queue read gate for deferred writes #99815 for [Due for payment 2026-09-15] Spend - Expenses are not shown in the table after splitting on group-by:from view #99805, a Search refetch reading pre-write state during exactly this window. Search's own search() skips it via skipWaitForWrites.
  4. Removed from all eight files.
  5. Renamed hasPendingDismissWrite, simplified executeWrite. Leaving the armed-barrier cancel (harmless, createTransaction returns void) and restartPendingSubmitWriteSafetyTimeout (pre-existing on main). Videos coming.

Please re-review

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Re-review — all clear

Verified every item against b8305e15. Nothing new, nothing blocking.

1. Comments — ✅ Fixed. flushWriteSession, "write session", and "flushed session" are all gone; grep over src/ and tests/ returns nothing for any of them, or for deferredLayoutWrite / deferOrExecuteWrite / DEFERRED_LAYOUT_WRITE_KEYS.

2. notifyNewAction — ✅ Fixed in all four, and your correction about main is right: the old deferOrExecuteWrite deferred path already notified before the write, so only the immediate path changed.

Worth noting startSplitBill came out strictly better than before. The only subscriber is scrollToBottomForCurrentUserAction (useReportActionsNewActionLiveTail.ts:227, MoneyRequestReportActionsList.tsx:613), and notifyNewAction silently drops when no subscriber is registered for the reportID. Firing immediately after dismissModalWithReport often beat the destination list's subscription; firing from onWriteStarted lands after the action exists. Navigating first is fine.

No test asserts notify ordering on these paths — the only behavioral assertion is in RejectMoneyRequestTest, which is untouched.

3. READ gate — ✅ Confirmed, withdrawing the concern. #99815 added the gate specifically because writeWhenReady left the queue empty during the barrier, letting a refetch read pre-write server state — #99805. That's the exact window I was asking about, so it's deliberate, not an inherited default.

4. Test comments — ✅ All eight removed.

5. Minor — ✅ hasPendingSubmitWrite rename and executeWrite: executeSendMoneyWrite both landed. Fine leaving the armed-barrier cancel and restartPendingSubmitWriteSafetyTimeout — neither is worth churn in this PR.


Only thing outstanding is the one you already called: [WIP] with the Screenshots/Videos sections empty. The code review is done on my side.


Next Steps: Reply with @MelvinBot <your feedback> to refine this review.

# Conflicts:
#	src/libs/actions/IOU/Split.ts
#	src/libs/actions/IOU/TrackExpense.ts
@JakubKorytko JakubKorytko changed the title [WIP] [Performance] Move Search and submit-expense onto write-readiness barriers and delete deferredLayoutWrite [Performance] Move Search and submit-expense onto write-readiness barriers and delete deferredLayoutWrite Sep 9, 2026
@JakubKorytko
JakubKorytko marked this pull request as ready for review September 9, 2026 11:49
@JakubKorytko
JakubKorytko requested review from a team as code owners September 9, 2026 11:49
@melvin-bot
melvin-bot Bot requested review from brunovjk and removed request for a team September 9, 2026 11:50
@melvin-bot

melvin-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

@brunovjk Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from trjExpensify and removed request for a team September 9, 2026 11:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 885290ae4d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@brunovjk

Copy link
Copy Markdown
Contributor

The abort listeners added in pendingSubmitWrite.ts and resolveWriteBarrier.ts don't appear to be removed after normal completion.

This is probably low impact because the signals are short-lived, but using {once: true} or removing the listener during cleanup would avoid retaining the closures unnecessarily?

@brunovjk

Copy link
Copy Markdown
Contributor

Potential edge case: isRetry is handled specially when there is no explicit writeBarrier, but the explicit-barrier branch returns earlier.

The combination of isRetry + writeBarrier + pendingSearchWrite therefore follows a different path. Worth adding a test for the expected behavior here?

@brunovjk

Copy link
Copy Markdown
Contributor

Potential regression from the previous deferred-write behavior: this now checks specifically for APP_STATE.BACKGROUND.

The previous flow appears to distinguish the app being inactive/not active from fully backgrounded. If inactive can occur during these navigation transitions, the pending Search write may now be handled differently.

@jmusial

jmusial commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@brunovjk thank you for the reivew, @JakubKorytko is coming back and since he's got better understanding of this PR it think it's better that we'll wait for him to address the comments 😄

@JakubKorytko

Copy link
Copy Markdown
Member Author

@brunovjk thanks for the thorough review. It would be better if it were a code review rather than plain comments, as it would be easier to answer and find in the code 😅 let me summarise:

Addressed

  • requestMoney notify timing

    How

    Moved to onWriteStarted on both write paths. Kept the microtask + NOTIFY_NEW_ACTION_DELAY inside the callback so the default submit path (write before navigation) still gives the report screen time to mount its subscriber. Only the ordering changed: notify can no longer fire before the write.

  • handleDismissToReport

    How

    The barrier wait itself is not needed there: createTransaction runs inside afterTransition, so the transition is already over and resolveWriteBarrier returns IMMEDIATE. What was missing is the pending-write signal for an empty destination report, same gap handleReportInRHPDismiss covers. Mirrored that: IMMEDIATE barrier + trackPendingSubmitWriteForReport when the destination is empty, isWriteStillComing now used.

  • Armed barrier not cancelled

    How

    Small correction on impact: settleAfterSubmit(false) already cleared the pending signal, what lingered was the TransitionTracker registration from armTransitionBarrier (bounded by MAX_TRANSITION_START_WAIT_MS). trackPendingSubmitWriteForReport now takes an optional cancelBarrier, called when the submission produces no write. Both armed call sites pass armed.cancel.

  • Abort listeners

    How

    removeEventListener in the finally rather than {once: true}. once would not help on the normal path since abort never fires there.

  • isRetry + writeBarrier + pendingSearchWrite test

    How Added. Expected: explicit-barrier branch wins, the wrapper still counts as Search's consumer so the signal clears on flush, no watch key published.

No change, by design

  • READ gate before barrier

    Why

    Predates the PR (claimReadGateForDeferredWrite is already in writeWhenReady on main). The gate is claimed early on purpose: otherwise a READ fired right after submit (e.g. OpenReport) races ahead of the deferred write and its response overwrites the optimistic data. None of the barriers here depend on a READ: transition barriers resolve on animation end, the Search barrier on the list's onLayout + transition end, which fires for the skeleton too. The constraint is documented in the writeWhenReady JSDoc.

  • Concurrent submissions

    Why

    Only one can be in flight: confirm is locked via isConfirming until createTransaction returns, and to submit again the user has to be back on a confirmation page, by which point Search has flushed or the safety timeout fired. pendingSubmitWrite.ts documents the same single-flight assumption. Even if two overlapped, consumption is by generation so a stale write cannot clear a newer signal, and consumers briefly seeing "pending" would be correct.

  • BACKGROUND vs inactive

    Why

    The old deferredLayoutWrite.ts on main has no AppState check at all, and the BACKGROUND check in resolveWriteBarrier predates this PR. inactive is transient on iOS (control center, call banner, app switcher) and returns to active within a second, so flushing there would defeat the deferral. background is the last state before the OS can suspend the process, the only point where a pending write has to go out or risk being lost.

@brunovjk

Copy link
Copy Markdown
Contributor

It would be better if it were a code review rather than plain comments

Sorry about that. I will review it in a moment. Thanks

@brunovjk

brunovjk commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
100169_android_web.mov
Android: mWeb Chrome
100169_android_web.mov
iOS: HybridApp
iOS: mWeb Safari
100169_ios_web.mov
MacOS: Chrome / Safari
100169_web_chrome.mov

@brunovjk brunovjk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@roryabraham

Copy link
Copy Markdown
Contributor

will review within the next ~24hrs. In the meantime, there are conflicts here

@Julesssss Julesssss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When creating IOUs via writeWhenReady they now only flush when a background event occurs. Previously they also flushed on inactive. Is there a case where the app is killed without the background lifecycle step has happened? For example, app is killed by user in app switcher (I'm not sure if app switcher triggers the iOS background lifecycle event or not)

*/
function resolveWatchKey(tracking: TrackingMutableState, setOptimisticWatchKey: React.Dispatch<React.SetStateAction<OnyxKey | undefined>>): (() => void) | undefined {
const latestKey = getOptimisticWatchKey(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH);
const latestKey = getSearchWriteWatchKey();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves the optimistic watch key from the deferred write channel and

Function docs could be updated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid, updated to:

Looks up the Onyx key of the optimistic item created by the pending Search write and

@roryabraham roryabraham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huge diff, but nothing jumped out at me. LGTM 👍🏼

@roryabraham
roryabraham merged commit 661830e into Expensify:main Sep 24, 2026
34 of 35 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.4.94-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site changes are required for [Performance] Move Search and submit-expense onto write-readiness barriers and delete deferredLayoutWrite, so I did not create a docs PR.

This PR changes only when optimistic data is written after you submit an expense. It does not change any feature, setting, button, label, or user flow that App/docs/articles describes.

What I checked
  • The PR changes internal write timing for request money, track expense, split, send money, invoice, per diem, and Search. It also deletes the old deferredLayoutWrite channel system.
  • No src/languages/* files changed, and no user-facing copy was added or removed.
  • The remaining files are internal helpers, hooks, and tests. None of them change what you see or how a flow works.

view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.94-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot MelvinBot mentioned this pull request Oct 6, 2026
40 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants